package com.ticket.sass.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ticket.sass.common.entity.tenant.HallEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ywb
 * @since 2022-09-26
 */
@Mapper
public interface HallMapper extends BaseMapper<HallEntity> {
    @Select("""
        SELECT hall.id, hall."name", hall.code, map.price_scheme_id
        FROM halls hall
        INNER JOIN price_scheme_hall_maps map ON hall.id = map.hall_id
        WHERE map.price_scheme_id IN (${priceSchemeIdsString})
        AND map.deleted_at IS NULL
        AND hall.deleted_at IS NULL
    """)
    List<HallEntity> queryHallsByPriceSchemeIds(@Param("priceSchemeIdsString") String priceSchemeIdsString);
    
    @Select("SELECT halls.id, halls.name " +
        "FROM halls halls " +
        "INNER JOIN coupon_hall_maps map ON halls.id = map.hall_id " +
        "WHERE map.coupon_id = #{couponId} " +
        "AND map.deleted_at IS NULL " +
        "AND halls.deleted_at IS NULL")
    List<HallEntity> queryHallsByCouponId(@Param("couponId") Long couponId);
}
